package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-20
 * Time: 15:46
 */
class MyArray {
    private Object[] obj = new Object[10];

    public void setObj(int pos, Object val) {
        this.obj[pos] = val;
    }

    public Object getObj(int pos) {
        return obj[pos];
    }
}

class MySuperArray<T> {
    public T[] array = (T[]) new Object[10];

    public T getArray(int pos) {
        return this.array[pos];
    }

    public void setArray(int pos, T val) {
        this.array[pos] = val;
    }
}

public class Test {


    public static void main(String[] args) {
        SeqList myList = new SeqList(10);
        myList.add(1);
        myList.add(2);
        myList.add(3);
        myList.add(4);
        myList.add(5);
        myList.add(1);
        myList.display();
        myList.remove(1);
        myList.display();
        myList.clear();

/*        myList.display();
        myList.add(99, 0);
        myList.add(99, 0);
        myList.display();
        System.out.println(myList.contains(0));
        myList.display();
        System.out.println("10's index:" + myList.indexOf(10));
        System.out.println("100's index:" + myList.indexOf(100));
        System.out.println(myList.get(100));*/
//        myList.set(0, 9);
//        myList.display();
    }


    public static void main2(String[] args) {
        MySuperArray<Integer> mySuperArray1 = new MySuperArray<>();
        mySuperArray1.setArray(0, 1);
        System.out.println(mySuperArray1.getArray(0));
        MySuperArray<String> mySuperArray2 = new MySuperArray<>();
        mySuperArray2.setArray(1, "hello");
        System.out.println(mySuperArray2.getArray(1));

    }

    public static void main1(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setObj(0, 100);
        myArray.setObj(1, "111");
        System.out.println(myArray.getObj(0));
        String str = (String) myArray.getObj(1);
    }

/*    public static void main(String[] args) {
        Object[] objects = new Object[10];
        objects[0] = 1;
        objects[1] = "11";
        System.out.println(objects[0]);
        System.out.println(objects[1]);
    }*/
}
